﻿using System;
using System.Linq.Expressions;

namespace _5E.Infrastructure.Expression
{
    public static class PropertyNameHelper
    {
        public static string ResolvePropertyName<T>(Expression<Func<T, object>> experssion)
        {
            var expr = experssion.Body as MemberExpression;
            if (null == expr)
            {
                var u = experssion.Body as UnaryExpression;
                expr = u.Operand as MemberExpression;
            }
            return expr.ToString().Substring(expr.ToString().IndexOf(".") + 1);
        }
    }
}
